﻿using UnityEngine;

namespace Core
{
    public class GameContext : AbstractGameContext
    {
        public TblGame.Conf Conf { get; private set; }

        public virtual void Awake(MonoBehaviour mono, TblGame.Conf conf)
        {
            this.mono = mono;
            gameObject = mono.gameObject;

            Conf = conf;

            InstanceId = Utils.ID.Get();
            SetSG(Context.Sys, this);
            Name = conf.Name;
        }

        public override void Dispose()
        {
            if (IsDisposed) return;
            base.Dispose();

            Factory.Dispose();
            Factory = null;
        }

        public virtual void SetVariant(VariantInfo info) { }


        public virtual void Enter()
        {
            Evt.Run(GameEvent.ENTER);
        }

        public virtual void Play()
        {
            Evt.Run(GameEvent.PLAY);
        }

        public virtual void Pause()
        {
            Evt.Run(GameEvent.PAUSE);
        }

        public virtual void Resume()
        {
            Evt.Run(GameEvent.RESUME);
        }

        public virtual void Return()
        {
            Evt.Run(GameEvent.RETURN);
        }

        public virtual void Exit()
        {
            Evt.Run(GameEvent.EXIT);
        }
    }
}
